<?php
/**
 * Created by PhpStorm.
 * User: GZ-1
 * Date: 2017/6/7
 * Time: 18:09
 */

include_once "../util.php";

$upfile=$_FILES["flag"];
$usid=$_REQUEST['usid'];
if(empty($upfile) || empty($usid)){
    echo json_encode(array(
        'stats'=>0,
        'msg'=>'数据不齐全'
    ));
    return;
}
move_uploaded_file($upfile["tmp_name"],  $upfile["name"]);

$base64_img = base64EncodeImage($upfile["name"]);

$sql ="UPDATE `users` SET `flag`='$base64_img' WHERE `usid`='$usid'";
$result=mysqli_query($conn,$sql);
if($result){
    unlink ($upfile["name"]);
    echo json_encode(array(
        'stata'=>1,
        'flag'=>$base64_img
    ));
}else{
    echo json_encode(array(
        'stats'=>0,
        'msg'=>'保存数据库失败'
    ));
}


